<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>

<head>
	<meta charset="UTF-8">
	<title>个人中心-azhuo商城</title>
	<link rel="shortcut icon" href="${pageContext.request.contextPath}/image/logo/xyz.ico" type="image/x-icon" />
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/style.css">

	<script src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
	<script type="text/javascript">
		function editData(uid, columnName, value) {

			var newValue = prompt("请输入修改的后的值", value);
			if (newValue == null || newValue.length <= 0) {
				return;
			}

			$.ajax({
				type: "POST",// 请求的方式默认为get 改为Post
				url: "${pageContext.request.contextPath}/UserServlet",// 往服务器端请求的地址 写成绝对路径
				data: {
					method: "editData",
					uid: uid,
					columnName: columnName,
					value: newValue
				},// 往服务器端发送的数据
				// 接受服务器端数据函数 回调函数
				success: function (data) {
					// data是服务器返回的数据
					if (data) {
						// 如果不是密码，修改显示的值
						if(columnName.search("password") == -1){
							$("#"+columnName).text(newValue);
						}
						alert("修改成功！");
					}
				}
			});

			//var path = encodeURI("${pageContext.request.contextPath}/UserServlet?method=editData&uid=" + uid + "&columnName=" + columnName + "&value=" + newValue);
			//console.log(path);

			$.post(path);
		}
	</script>

</head>

<body>

	<!-- ----------------------------------- start head ----------------------------------- -->
	<jsp:include page="/jsps/includes/head.jsp" />
	<!-- ----------------------------------- end head ----------------------------------- -->


	<!-- ----------------------------------- start banner_x ----------------------------------- -->
	<div class="banner_x center">
		<a href="${pageContext.request.contextPath }/index.jsp" target="_self">
			<div class="logo fl"></div>
		</a>
		<div class="nav fl">
			<ul>
				<li><a href="${pageContext.request.contextPath }/liebiao.jsp" target="_blank">azhuo品牌</a></li>
				<li><a href="">生活馆</a></li>
				<li><a href="">智能硬件</a></li>
				<li><a href="">司法拍卖</a></li>
				<li><a href="">电视</a></li>
				<li><a href="">路由器</a></li>
				<li><a href="">服务</a></li>
				<li><a href="">azhuo社区</a></li>
			</ul>
		</div>
	</div>
	<!-- ----------------------------------- end banner_x ----------------------------------- -->

	<!-- ----------------------------------- self_info ----------------------------------- -->
	<div class="grzxbj">
		<div class="selfinfo center">
			<div class="lfnav fl">
				<div class="ddzx">订单中心</div>
				<div class="subddzx">
					<ul>
						<li><a href="${pageContext.request.contextPath}/jsps/order/orders.jsp">我的订单</a></li>
						<li><a href="">意外保</a></li>
						<li><a href="">团购订单</a></li>
						<li><a href="">评价晒单</a></li>
					</ul>
				</div>
				<div class="ddzx">个人中心</div>
				<div class="subddzx">
					<ul>
						<li>
							<a href="${pageContext.request.contextPath}/jsps/users/myInfo.jsp"
								style="color:#ff6700;font-weight:bold;">我的个人中心</a>
						</li>
						<li><a href="">消息通知</a></li>
						<li><a href="">优惠券</a></li>
						<li><a href="">收货地址</a></li>
					</ul>
				</div>
			</div>
			<div class="rtcont fr">
				<div class="grzlbt ml40">我的资料</div>
				<div class="subgrzl ml40">
					<span>用户名</span>
					<span id="username">${user.username}&nbsp;</span>
					<span id="usernameMsg">${messages.username}&nbsp;</span>
					<span>
						<a href="javaScript:;" onclick="editData('${user.uid}', 'username', '${user.username}')">编辑</a>
					</span>
				</div>
				<div class="subgrzl ml40">
					<span>密码</span>
					<span>************&nbsp;</span>
					<span id="passwordMsg">${messages.password}&nbsp;</span>
					<span>
						<a href="javaScript:;" onclick="editData('${user.uid}', 'password')">编辑</a>
					</span>
				</div>
				<div class="subgrzl ml40">
					<span>手机号</span>
					<span id="phone">${user.phone}&nbsp;</span>
					<span id="phoneMsg">${messages.phone}&nbsp;</span>
					<span>
						<a href="javaScript:;" onclick="editData('${user.uid}', 'phone', '${user.phone}')">编辑</a>
					</span>
				</div>
				<div class="subgrzl ml40">
					<span>email</span>
					<span id="email">${user.email}&nbsp;</span>
					<span id="emailMsg">${messages.email}&nbsp;</span>
					<span>
						<a href="javaScript:;" onclick="editData('${user.uid}', 'email', '${user.email}')">编辑</a>
					</span>
				</div>
				<div class="subgrzl ml40">
					<span>收货地址</span>
					<span id="address">${user.address}&nbsp;</span>
					<span id="addressMsg">${messages.address}&nbsp;</span>
					<span>
						<a href="javaScript:;" onclick="editData('${user.uid}', 'address', '${user.address}')">编辑</a>
					</span>
				</div>
			</div>
			<div class="clear"></div>
		</div>
	</div>
	<!-- ----------------------------------- self_info ----------------------------------- -->

	<!-- ----------------------------------- start footer ----------------------------------- -->
	<jsp:include page="/jsps/includes/footer.jsp" />
	<!-- ----------------------------------- end login ----------------------------------- -->

</body>

</html>